const fs = require("fs");
 var readline = require("readline");

let arr1 = [];
let arr2 = [];

const r1 = readline.createInterface({
  input: fs.createReadStream("./data/UKAsin1.txt"),
});
r1.on("line", function (line) { //事件监听
  arr1.push(line);
}).on("close", ()=>{

    console.log(arr1.length);
    const r2 = readline.createInterface({
      input: fs.createReadStream("./data/UKAsin0.txt"),
    });
    r2.on("line", function (line) { //事件监听
      arr2.push(line);
    }).on("close", ()=>{
      console.log(arr2.length);
      let newArr = arrayWeightRemoval(arr1, arr2);
      console.log(newArr.length);
      newArr.forEach((dataCode) => {
        fs.appendFileSync("./data/newdfAsin2899.txt", dataCode + "\n", "utf8");
      });

    });
});




// let arr1 = ["a", "b", "c", "d", "ere"];
// let arr2 = ["a", "c", "d", "f", "fd"];


  // 数据去重
  let arrayWeightRemoval = function (array1, array2) {

    //临时数组存放
    var tempArray1 = []; //临时数组1
    var tempArray2 = []; //临时数组2

    for (let i = 0; i < array2.length; i++) {
      tempArray1[array2[i]] = true; //将数array2 中的元素值作为tempArray1 中的键，值为true；
    }

    for (let i = 0; i < array1.length; i++) {
      if (!tempArray1[array1[i]]) {
        tempArray2.push(array1[i]); //过滤array1 中与array2 相同的元素；
      }
    }
    return tempArray2;
  };
  // arrayWeightRemoval(arr1, arr2);

  //返回结果 [b,f] ;
